#!/bin/sh
# -----------------------------------------------------------------------------
# @author guang.hu
#

DIR="/Users/huguang/guangyao"
#DIR=`dirname $0`
PLATFORM_DIR="${DIR}/hybris/hybris/bin/platform"
LOG_DIR="${DIR}/hybris/hybris/log/tomcat"

MODE=$1

if [ "$MODE" = "" ] ; then
	MODE="run"
fi

case $MODE in
	"start" | "-b" )
		COMMAND="sh hybrisserver.sh start"
		cd ${PLATFORM_DIR}
        exec $COMMAND
		;;
	"debug" | "-d" )
	    cd ${PLATFORM_DIR}
		sh hybrisserver.sh debug
		;;
	"stop" | "-q" )
	    cd ${PLATFORM_DIR}
		sh hybrisserver.sh stop
		;;
    "tail" | "-t" )
	    cd ${LOG_DIR}
		tail -n 200 -f console-$(date +%Y%m%d).log
		;;
	"ant")
		cd ${PLATFORM_DIR}
		. ./setantenv.sh
		ant all
		;;
	"clean")
		cd ${PLATFORM_DIR}
		. ./setantenv.sh
		ant clean all
		;;
	"build")
		cd ${PLATFORM_DIR}
		. ./setantenv.sh
		ant build
		;;
	"deploy")
		cd ${PLATFORM_DIR}
		. ./setantenv.sh
		ant deploy
		;;
    "version" | "-v" )
		COMMAND="java -cp ../lib/catalina.jar org.apache.catalina.util.ServerInfo"
		;;
	* )
		COMMAND="sh hybrisserver.sh ${MODE}"
		;;
esac


